#!/bin/bash

#osdarray=(`df |grep "osd\/ceph-" | awk -F '-' '{print $NF}'|sort -n -u 2>/dev/null`)
osdarray=(`service ceph status|grep -E "^osd"|awk -F ':' '{print $1}'|sort -d -u 2>/dev/null`)
length=${#osdarray[@]}
printf "{\n"
printf  '\t'"\"data\":["
for ((i=0;i<$length;i++))
do
        printf '\n\t\t{'
        printf "\"{#OSD_NAME}\":\"${osdarray[$i]}\"}"

        if [ $i -lt $[$length-1] ];then
                printf ','
        fi
done
printf  "\n\t]\n"
printf "}\n"
